﻿#include <CommonUnits/Units/Voltage.h>
#include <gtest/gtest.h>

TEST(VoltageTest, CastTest)
{
    EXPECT_EQ(CU::Volt(1e3), CU::Kilovolt(1));
    EXPECT_EQ(CU::Kilovolt(1e3), CU::Megavolt(1));
    EXPECT_EQ(CU::Megavolt(1e3), CU::Gigavolt(1));
    EXPECT_EQ(CU::Gigavolt(1e3), CU::Teravolt(1));
    EXPECT_EQ(CU::Teravolt(1e3), CU::Petavolt(1));
    EXPECT_EQ(CU::Petavolt(1e3), CU::Exavolt(1));
    EXPECT_EQ(CU::Millivolt(1e3), CU::Volt(1));
    EXPECT_EQ(CU::Microvolt(1e3), CU::Millivolt(1));
    EXPECT_EQ(CU::Nanovolt(1e3), CU::Microvolt(1));
    EXPECT_EQ(CU::Picovolt(1e3), CU::Nanovolt(1));
    EXPECT_EQ(CU::Femtovolt(1e3), CU::Picovolt(1));
    EXPECT_EQ(CU::Attovolt(1e3), CU::Femtovolt(1));
}

TEST(VoltageTest, Literals)
{
    using namespace CU::Voltage::Literals;
    EXPECT_EQ(1e3_V, 1.0_kV);
    EXPECT_EQ(1e3_kV, 1.0_MV);
    EXPECT_EQ(1e3_MV, 1.0_GV);
    EXPECT_EQ(1e3_GV, 1.0_TV);
    EXPECT_EQ(1e3_TV, 1.0_PV);
    EXPECT_EQ(1e3_PV, 1.0_EV);
    EXPECT_EQ(1e3_mV, 1.0_V);
    EXPECT_EQ(1e3_uV, 1.0_mV);
    EXPECT_EQ(1e3_nV, 1.0_uV);
    EXPECT_EQ(1e3_pV, 1.0_nV);
    EXPECT_EQ(1e3_fV, 1.0_pV);
    EXPECT_EQ(1e3_aV, 1.0_fV);
}

TEST(VoltageTest, ToUnit)
{
    using namespace CU::Voltage::Literals;
    EXPECT_EQ(1e3_V, CU::Voltage::toUnit<CU::Volt>(1, CU::Kilovolt::unit()));
    EXPECT_EQ(1e3_kV, CU::Voltage::toUnit<CU::Kilovolt>(1, CU::Megavolt::unit()));
    EXPECT_EQ(1e3_MV, CU::Voltage::toUnit<CU::Megavolt>(1, CU::Gigavolt::unit()));
    EXPECT_EQ(1e3_GV, CU::Voltage::toUnit<CU::Gigavolt>(1, CU::Teravolt::unit()));
    EXPECT_EQ(1e3_TV, CU::Voltage::toUnit<CU::Teravolt>(1, CU::Petavolt::unit()));
    EXPECT_EQ(1e3_PV, CU::Voltage::toUnit<CU::Petavolt>(1, CU::Exavolt::unit()));
    EXPECT_EQ(1e3_mV, CU::Voltage::toUnit<CU::Millivolt>(1, CU::Volt::unit()));
    EXPECT_EQ(1e3_uV, CU::Voltage::toUnit<CU::Microvolt>(1, CU::Millivolt::unit()));
    EXPECT_EQ(1e3_nV, CU::Voltage::toUnit<CU::Nanovolt>(1, CU::Microvolt::unit()));
    EXPECT_EQ(1e3_pV, CU::Voltage::toUnit<CU::Picovolt>(1, CU::Nanovolt::unit()));
    EXPECT_EQ(1e3_fV, CU::Voltage::toUnit<CU::Femtovolt>(1, CU::Picovolt::unit()));
    EXPECT_EQ(1e3_aV, CU::Voltage::toUnit<CU::Attovolt>(1, CU::Femtovolt::unit()));
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}